/**
*      author: Y_Yao
*      created: 2024-12-07 23:51:06
**/

#include<bits/stdc++.h>

#define int LL
using namespace std;
using LL = long long;
const LL LLINF = 1e18;
const int INF = 0x3f3f3f3f;
int h,w,d;
const int N = 10 + 7;
char a[N][N];

int count(int i,int j,int x,int y)
{
    return abs(x - i) + abs(y - j);
}

void solve()
{
    cin >> h >> w >> d;
    for(int i = 1;i <= h;i++)
    {
        for(int j = 1;j <= w;j++)
        {
            cin >> a[i][j];
        }
    }

    int ans = 0;
    int ret = 0;
    for(int i = 1;i <= h;i++)
    {
        for(int j = 1;j <= w;j++)
        {
            if(a[i][j] == '#') continue;
            for(int x = 1;x <= h;x++)
            {
                for(int y = 1;y <= w;y++)
                {
                    ans = 0;
                    if(i == x && y == j) continue;
                    if(a[x][y] == '#') continue;
                    for(int k = 1;k <= h;k++)
                    {
                        for(int m = 1;m <= w;m++)
                        {
                            if(a[k][m] == '#') continue;
                            if(count(i,j,k,m) <= d || count(x,y,k,m) <= d)
                            {
                                ans++;
                            }
                        }
                    }    
                    ret = max(ret,ans);                
                }
            }
        }
    }

    cout << ret << endl;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    //cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}